﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace METU_CMT.Business
{
    public class Event
    {
        private bool submissionExist;
        private DateTime dueDate;
        private int eventId;
        private string description;
        private int mailState;

        public Event(int eventId)
        {
            EventTableAdapter _eventTableAdapter = new EventTableAdapter();
            dueDate = _eventTableAdapter.GetDueDate(eventId);
            description = _eventTableAdapter.GetDescription(eventId);
            submissionExist = _eventTableAdapter.GetSubmissionExists(eventId);
            MailState = _eventTableAdapter.GetMailState(eventId);
            this.eventId = eventId;
        }

        public Event(string date, string time, string description, bool submission)
        {
            submissionExist = submission;
            bool _successfull;
            DateTime _dueDate = CommonMethods.ToDateTime(date + ' ' + time, "dd.MM.yyyy HH:mm", out _successfull);

            if (_successfull == false)
            {
                return;
            }

            dueDate = _dueDate;
            this.description = description;
        }
        
        public bool SubmissionExist
        {
            get { return submissionExist; }
            set { submissionExist = value; }
        }

        public DateTime DueDate
        {
            get { return dueDate; }
            set { dueDate = value; }
        }

        public int EventId
        {
            get { return eventId; }
            set { eventId = value; }
        }

        public string Description
        {
            get { return description; }
            set { description = value; }
        }

        public string DueDateDayFormat
        {
            get { return dueDate.ToString("dd.MM.yyyy"); }
        }

        public string DueDateTimeFormat
        {
            get { return dueDate.ToString("HH:mm"); }
        }

        public int MailState
        {
            get { return mailState; }
            set { mailState = value; }
        }
    }
}